#coding=utf-8
from content import ReplyContent
from google.appengine.ext import db
from subscribe import SubscribeOther, Subscribe
__author__ = 'WangJian'

def addInitReplay(username,realName='',tel='',mtel=''):

    replyContent = ReplyContent()
    replyContent.maincode = 'a999'#主编号
    replyContent.code = 'a999-1-s1-'+username#编号
    replyContent.father = 'a999-1-s1'#父级
    replyContent.content = '****'#内容
    replyContent.replyType = '1'
    replyContent.status = '1'
    replyContent.level='101'
    rlist=ReplyContent().all().filter('code =',replyContent.code)
    if rlist.count()!=0:
        db.delete(rlist.fetch(10))
    replyContent.put()


    replyContent = ReplyContent()
    replyContent.maincode = 'a999'#主编号
    replyContent.code = 'a999-2-s1-'+username#编号
    replyContent.father = 'a999-2-s1'#父级
    replyContent.content = '*;*1*2*3*4*'#内容
    replyContent.replyType = '15'
    replyContent.status = '1'
    replyContent.level='101'
    rlist=ReplyContent().all().filter('code =',replyContent.code)
    if rlist.count()!=0:
        db.delete(rlist.fetch(10))
    replyContent.put()
    
#    replyContent2 = ReplyContent()
#    replyContent2.maincode = 'a999'#主编号
#    replyContent2.code = 'a999-9-2-s1-'+username#编号
#    replyContent2.content = '**'+username+'**'+realName+'**'+tel+'**'+mtel+'**'#内容
#    replyContent2.replyType = '4'
#    replyContent2.status = '1'
#    replyContent2.level='101'
#    replyContent2.put()
    ##订阅
#    s=Subscribe()
#    s.userName=username
#    s.maincode='a999'
#    s.subscribeType='1'
#    s.status='1'
#    s.put()
#    
#    greeting = SubscribeOther()
#    greeting.userName = username
#    greeting.maincode = 'a999'
#    greeting.code = 'a999-1'
#    greeting.father = 'a999'
#    greeting.level = '2'
#    greeting.subscribeType = '1'
#    greeting.put()
#    greeting = SubscribeOther()
#    greeting.userName = username
#    greeting.maincode = 'a999'
#    greeting.code = 'a999-1-s1'
#    greeting.father = 'a999-1'
#    greeting.level = '100'
#    greeting.subscribeType = '1'
#    greeting.put()
    greeting = SubscribeOther()
    greeting.userName = username
    greeting.maincode = 'a999'
    greeting.code = 'a999-1-s1-'+username
    greeting.father = 'a999-1-s1'
    greeting.level = '101'
    greeting.subscribeType = '0'
    greeting.put()


    greeting = SubscribeOther()
    greeting.userName = username
    greeting.maincode = 'a999'
    greeting.code = 'a999-2-s1-'+username
    greeting.father = 'a999-2-s1'
    greeting.level = '101'
    greeting.subscribeType = '0'
    greeting.put()
#    greeting2 = SubscribeOther()
#    greeting2.userName = username
#    greeting2.maincode = 'a999'
#    greeting2.code = 'a999-9-2-s1-'+username
#    greeting2.father = 'a999-9-2-s1'
#    greeting2.level = '101'
#    greeting2.subscribeType = '0'
#    greeting2.put()
